<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <!--<li>
                                <label>发送时间：</label>
                                <input type="text" class="time-input" placeholder="请选择发送时间" name="sendTime"/>
                            </li>-->
                            <li>
                                <label>编号：</label>
                                <input type="text" name="boatCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:command:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:command:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:command:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:command:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:command:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:command:remove')}]];
        var prefix = ctx + "system/command";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "指令记录",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: true
                },
                {
                    field: 'commandType',
                    title: '指令类型',
                    formatter: function(value){
                        let cmdName = value

                        switch (value){
                            case 0:
                                cmdName = "模式控制";
                                break;
                            case 1:
                                cmdName = "平台地址修改";
                                break;
                            case 2:
                                cmdName = "发送模式"
                                break;
                            case 3:
                                cmdName = "跑偏半径"
                                break;
                            case 4:
                                cmdName = "轨迹点设置"
                                break;
                            case 5:
                                cmdName = "航迹规划"
                                break;
                            case 6:
                                cmdName = "数字自毁"
                                break;
                            case 7:
                                cmdName = "平台自沉"
                                break;
                            case 8:
                                cmdName = "电推工作"
                                break;
                            case 9:
                                cmdName = "舵角"
                                break;
                            case 10:
                                cmdName = "载荷开关"
                                break;
                            case 11:
                                cmdName = "自动下发"
                                break;
                            case 12:
                                cmdName = "数据上报频率"
                                break;
                            case 13:
                                cmdName = "艇ID"
                                break;
                            case 14:
                                cmdName = "艇体状态"
                                break;
                            case 15:
                                cmdName = "浮块状态"
                                break;
                            case 16:
                                cmdName = "声光报警"
                                break;
                            case 17:
                                cmdName = "数据存储自动销毁"
                                break;
                            case 18:
                                cmdName = "平台自动注水销毁"
                                break;
                            case 19:
                                cmdName = "AIS避障功能"
                                break;
                            case 20:
                                cmdName = "工作模式"
                                break;
                            case 21:
                                cmdName = "工作模式"
                                break;
                            case 22:
                                cmdName = "驻航"
                                break;
                            case 23:
                                cmdName = "加密"
                                break;
                            case 24:
                                cmdName = "声通信"
                                break;
                        }
                        return cmdName
                    }
                },
                {
                    field: 'sendTime',
                    title: '发送时间'

                },
                {
                    field: 'boatCode',
                    title: '艇编号'
                },
                {
                    field: 'serialNum',
                    title: '指令序号'
                },
                {
                    field: 'result',
                    title: '下发结果',
                    formatter: function(value){
                        if(value == 0){
                            return '下发'
                        }else if(value == 1){
                            return '执行成功'
                        }else {
                            return '执行失败'
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>